package GameUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.URL;
import java.util.Observable;
import java.util.Observer;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
 * This class about the picture ui
 * @author wat wattanagaroon
 * @author parintorn panya
 * @version 2013/05/10
 */

public class PictureUI extends JFrame implements Observer{
	public JPanel panelpicturecenter;
	private String imageiconstandard;
	private String rightatk = "picture/rightatkver2.gif";;
	private String leftatk = "picture/leftatkver2.gif";
	private ImageIcon[] images = new ImageIcon[3];
	private int count = 0;
	private  JLabel picturestandard;
	public PictureUI(){
		inticomponent();
	}
	/**
	 * This is the inticomponent
	 */
	private void inticomponent() {
		panelpicturecenter = new JPanel();
		imageiconstandard = "picture/standard.gif";
		addimages(imageiconstandard);
		addimages(rightatk);
		addimages(leftatk);
		standardpicture();
	}
	/**
	 * This method add the images to the ui
	 * @param image picture that want to add
	 */
	private void addimages(String image){
		ClassLoader loader = this.getClass().getClassLoader();
		URL url = loader.getResource(image);
		images[count] = new ImageIcon(url);
		count++;
	}
	/**
	 * This is the method for add standard picture,
	 */
	public void standardpicture(){
		panelpicturecenter.removeAll();
		picturestandard = new JLabel(images[0]);
		panelpicturecenter.add(picturestandard,BorderLayout.CENTER);
	}
	/**
	 * This is the method for change the picture.
	 * @param image picture that want to change.
	 */
	public void changePicture (ImageIcon image){
		JLabel label = new JLabel(image);
		panelpicturecenter.removeAll();
		panelpicturecenter.add(label,BorderLayout.CENTER);
	}
	/**
	 * The method for get the image
	 * @return array of image icon
	 */
	public ImageIcon[] getImages(){
		return images;
	}
	/**
	 * Runnable method
	 */
	public void run() {
		pack();	
	}
	@Override
	public void update(Observable arg0, Object arg1) {
	}
}
